package com.ocom.payhandle.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ocom.common.entity.human.EntityRoommateInfo;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.common.enums.MasterSlaveEnum;
import com.ocom.mysql.aspect.DataSourceAspect;
import com.ocom.payhandle.dao.IDaoRoommateInfo;
import com.ocom.payhandle.service.RoommateInfoService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoommateInfoServiceImpl extends ServiceImpl<IDaoRoommateInfo, EntityRoommateInfo> implements RoommateInfoService {

    /**
     * 新增同住人（addRoommate）
     * */
    @DataSourceAspect(type = DataSourceEnum.PART_DB,isMaster = MasterSlaveEnum.MASTER)
    @Override
    public boolean AddRoommate(Long companyId, EntityRoommateInfo entityRoommateInfo) {
         return this.save(entityRoommateInfo);
    }

    /**
     * 新增同住人（addRoommate）
     * */
    @Override
    @DataSourceAspect(type = DataSourceEnum.PART_DB,isMaster = MasterSlaveEnum.SLAVE)
    public List<EntityRoommateInfo> getRoomPerson(Long companyId, Long pId) {
        QueryWrapper<EntityRoommateInfo> queryWrapper=new QueryWrapper<>();
        queryWrapper.select("name","phone","url","openid");
        queryWrapper.eq("com_id",companyId);
        queryWrapper.eq("p_id",pId);
        return this.list(queryWrapper);
    }


}
